{{- /*
Notes in article.

@param {string} (positional parameter 0) [tip|important|warning|info]

@returns {template.HTML}

@examples

  {{< alert "tip" >}}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque in egestas lacus, sed faucibus augue.
  {{< /alert >}}
*/ -}}

{{ $type := (.Get 0) }}
{{ $types := (slice "important" "info" "tip" "warning") }}

{{ with ($type) }}
    {{ if (not (in ($types) .)) }}
        {{ (errorf "The type passed to the %q shortcode is invalid. The type must be one of %s. See %s." ($.Name) (delimit ($types) ", " ", or ") ($.Position)) }}
    {{ end }}
{{ end }}

{{ $icon := "fas fa-sticky-note" }}
{{ $css := "primary" }}

{{ if (eq ($type) "info") }}
    {{ $icon = "fas fa-info" }}
    {{ $css = "info" }}
{{ end }}

{{ if (eq ($type) "important") }}
    {{ $icon = "fas fa-exclamation-triangle" }}
    {{ $css = "warning" }}
{{ end }}

{{ if (eq ($type) "tip") }}
    {{ $icon = "fas fa-lightbulb" }}
    {{ $css = "success" }}
{{ end }}

{{ if (eq ($type) "warning") }}
    {{ $icon = "fas fa-circle-radiation" }}
    {{ $css = "danger" }}
{{ end }}

<div class="shortcode shortcode-{{ ($.Name) }}">
  <div class="alert alert-{{ ($css) }} d-flex overflow-hidden" role="alert">
    <div class="flex-shrink-0 align-self-center">
      <i class="{{ ($icon) }} fa-fw fa-2x"></i>
    </div>
    <div class="flex-grow-1 ms-3 overflow-hidden">
        {{ with (.Inner) }}{{ (. | $.Page.RenderString (dict "display" "block")) }}{{ end }}
    </div>
  </div>
</div>
